package com.fjnu.service.impl;

import com.fjnu.dao.CategoryDao;
import com.fjnu.dao.impl.CategoryDaoImpl;
import com.fjnu.entity.Category;
import com.fjnu.service.CategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
@Service
public class CategoryServiceImpl implements CategoryService {
    @Autowired
    private CategoryDao categoryDao;


    @Override
    public int insert(Category category) {
        return categoryDao.insert(category);
    }

    @Override
    public int delete(Integer categoryId) {
        return categoryDao.delete(categoryId);
    }

    @Override
    public List<Category> list() {
        return categoryDao.list();
    }

    @Override
    public int add(Category category) {
        category.setCreateTime(new Date(System.currentTimeMillis()));
        category.setUpdateTime(new Date(System.currentTimeMillis()));
        category.setParentId(0);
        category.setOrder(null);
        return categoryDao.add(category);
    }
}
